import DataManager from "./DataManager";
export default class Render {
  canvas = null;
  // RenderList = [];

  constructor(node) {
    this.DataManager = DataManager.instance();
    this.name =node?node.name:''
    this.order=0
    // 自动绘制
    this.unAutoRender=false
  }
  bindCanvas(canvas) {
    this.canvas = canvas;
  }

  render() {
    let draw = this.canvas.draw;
    let context = draw.context;

    context.save();

    draw.clear();
    context.translate(
      this.DataManager.worldTransForm.x,
      this.DataManager.worldTransForm.y
    );
    let renderDatas = this.DataManager.renderDatas;
    renderDatas.forEach((node) => {
      if(node.layer === this.name){
        node.render(context);
      }

    });

    context.restore();
  }
}
